﻿Imports System.Text

Public Class GeneratorFeedback
 
    Private _DOClassInfo As DTOClassInfo
    Public Property DOClassInfo() As DTOClassInfo
        Get
            Dim myDOClassInfo As DTOClassInfo = _DOClassInfo
            If myDOClassInfo Is Nothing Then
                myDOClassInfo = New DTOClassInfo
                _DOClassInfo = myDOClassInfo
            End If
            Return myDOClassInfo
        End Get
        Set(ByVal value As DTOClassInfo)
            _DOClassInfo = value
        End Set
    End Property

    Public Overloads Function ToString(ByVal aShowDetail As Boolean) As String
        'DO info
        Dim myText As New StringBuilder
        With myText
            .AppendLine("DO related")
            .Append(DOClassInfo.ToString(aShowDetail:=aShowDetail))
            .AppendLine()
        End With
        Return myText.ToString
    End Function
    Public Overrides Function ToString() As String
        Return ToString(False)
    End Function

End Class

Public Class DTOClassInfo

    Private _DOClassInfos As Dictionary(Of String, DOClassDetailInfo)
    Private ReadOnly Property DOClassInfos() As Dictionary(Of String, DOClassDetailInfo)
        Get
            Dim myDOClassInfos As Dictionary(Of String, DOClassDetailInfo) = _DOClassInfos
            If myDOClassInfos Is Nothing Then
                myDOClassInfos = New Dictionary(Of String, DOClassDetailInfo)
                _DOClassInfos = myDOClassInfos
            End If
            Return myDOClassInfos
        End Get
    End Property

    Public Function AddClassName(ByVal aName As String) As DOClassDetailInfo
        Dim myDOClassInfos As Dictionary(Of String, DOClassDetailInfo) = DOClassInfos
        If myDOClassInfos.ContainsKey(aName) Then Throw New ArgumentException("Class is already defined")
        Dim myNewDOClassInfo As New DOClassDetailInfo
        myDOClassInfos.Add(aName, myNewDOClassInfo)
        Return myNewDOClassInfo
    End Function

    Public ReadOnly Property NumberOfClasses() As Integer
        Get
            Return DOClassInfos.Count
        End Get
    End Property
    Public Overloads Function ToString(ByVal aShowDetail As Boolean) As String
        Dim myText As New StringBuilder
        With myText
            .AppendLine(String.Format("Number of Classes Generated:  '{0}'", NumberOfClasses))
            .AppendLine()
            If aShowDetail Then
                For Each myName As KeyValuePair(Of String, DOClassDetailInfo) In DOClassInfos
                    .AppendLine(String.Format("Class generated: {0}", vbTab & myName.Key))
                    .Append(myName.Value.ToString(aShowDetail))
                Next
            End If
        End With
        Return myText.ToString
    End Function
    Public Overrides Function ToString() As String
        Return ToString(False)
    End Function

End Class

Public Class DOClassDetailInfo

    Public Sub AddMethodName(ByVal aName As String)
        ListOfMethods.Add(aName)
    End Sub

    Public Sub AddPropertyName(ByVal aName As String)
        ListOfProperties.Add(aName)
    End Sub

    Public ReadOnly Property NumberOfMethods() As Integer
        Get
            Return ListOfMethods.Count
        End Get
    End Property

    Public ReadOnly Property NumberOfProperties() As Integer
        Get
            Return ListOfProperties.Count
        End Get
    End Property

    Private _ListOfMethods As List(Of String)
    Private Property ListOfMethods() As List(Of String)
        Get
            Dim myList As List(Of String) = _ListOfMethods
            If myList Is Nothing Then
                myList = New List(Of String)
                _ListOfMethods = myList
            End If
            Return myList
        End Get
        Set(ByVal value As List(Of String))
            _ListOfMethods = value
        End Set
    End Property

    Private _ListOfProperties As List(Of String)
    Private Property ListOfProperties() As List(Of String)
        Get
            Dim myList As List(Of String) = _ListOfProperties
            If myList Is Nothing Then
                myList = New List(Of String)
                _ListOfProperties = myList
            End If
            Return myList
        End Get
        Set(ByVal value As List(Of String))
            _ListOfProperties = value
        End Set
    End Property

    Public Overloads Function ToString(ByVal aShowDetail As Boolean) As String
        Dim myText As New StringBuilder
        With myText
            .AppendLine(String.Format("Number of Methods Generated:  '{0}'", NumberOfMethods))
            If aShowDetail Then
                For Each myName As String In ListOfMethods
                    .AppendLine(vbTab & myName)
                Next
            End If
            .AppendLine(String.Format("Number of Properties Generated:  '{0}'", NumberOfProperties))
            If aShowDetail Then
                For Each myName As String In ListOfProperties
                    .AppendLine(vbTab & myName)
                Next
            End If
            .AppendLine()
        End With
        Return myText.ToString
    End Function
    Public Overrides Function ToString() As String
        Return ToString(False)
    End Function

End Class

